/**
 * @描述：七牛获取数据上传的token值
 * @创建人：liyongwei
 * @创建时间：2015-10-11
 * @Copyright 上海越诚软件有限公司
 */
//var domain = "http://7xj8x8.com2.z0.glb.qiniucdn.com/";
var domain = "http://app.app-storage-node.com/";
var accessKey = "yRKbpf8qWWvZ2H1IvbVJMESfcQRJq9MltT-AUNUs";
var secretKey = "puerTsw7dOHjFFYQ07UMJ1zu-IgttWVCak9Rwh5Q";
var url = "http://fusion.qiniuapi.com/refresh";
function run() {
 
    			_log.INFO("body-----refresh");


    var resultMap = _webTools.jsonStringToMap("{}");
	
	try{
		var keys = _webParams.getParamValues().get("keys");
		if(keys != "" && keys != null)
		{
			keys = keys.split(",");
			var keysLength = keys.length;
			var keysIntLeng = Math.floor(keysLength/100)+1;
			_log.INFO("keysIntLeng"+keysIntLeng);
			var paramMap = _webTools.jsonStringToMap("{}");
			var headerMap = _webTools.jsonStringToMap("{}");
			headerMap.put("Authorization" , "QBox yRKbpf8qWWvZ2H1IvbVJMESfcQRJq9MltT-AUNUs:W7H-eQ2bxXc1aE2Upmh96ja5IKU=");

            for (var j = 1 ; j < keysIntLeng+1; j++ )
            {
				var urls = new Array();
                var start = (j-1)*100;
                var end = j*100-1;
                end = end<=keysLength?end:keysLength;
				_log.INFO("end"+end);
				_log.INFO("start"+start);
                for (var i = start ; i < end; i++ )
                {
                    var key = keys[i];
                    if(keys != "" && keys != null)
                    {
                        urls.push('"'+domain+key+'"');
                    }
                }
                   
				_log.INFO("keys"+keys);
				_log.INFO("urls"+urls);

				var body = '{"urls":['+urls+']}';
				_log.INFO("body-----"+body);

				var resultData = _http.sendPost("http://fusion.qiniuapi.com/refresh",body,paramMap, headerMap);
					_log.INFO("resultData"+resultData);

            }


		
		
			resultMap.put("00","成功");

		}

	}catch(e){
		resultMap.put("01","失败");
	}
   	return resultMap;				
}
run();